package com.macro.mall.controller;

import com.kuaidi100.sdk.contant.CompanyConstant;
import com.kuaidi100.sdk.request.QueryTrackParam;
import com.kuaidi100.sdk.response.QueryTrackResp;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.sdk.Kuaidi100;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @ClassName KuaidiController
 * @Package com.macro.mall.controller
 * @Description TODO
 * @Author wsx
 * @Date 2024/8/713:57
 * @Version V1.0
 * @Copyright yunshan
 */
@RestController
@Api(tags = "KuaidiController")
@Tag(name = "KuaidiController", description = "快递")
@RequestMapping("/Kuaidi")
public class KuaidiController {
    @Autowired
    private Kuaidi100 kuaidi100;

    @ApiOperation("查询实时快递信息")
    @PostMapping("queryTrack")
    public CommonResult<Object> queryTrack(@RequestBody QueryTrackParam queryTrackParam) {
        QueryTrackResp result = null;
        try {
            result = kuaidi100.queryTrack(queryTrackParam);
            if(result.getStatus().equals("200")){
                return CommonResult.success(result);
            }
            return CommonResult.failed();
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }
    }
}
